import { createApp, type App } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import './style.css'
import AppComponent from './App.vue'
import router from './router'
import { useUserStore } from './stores/user'
import type { Router } from 'vue-router'

const app = createApp(AppComponent)
const pinia = createPinia()

app.use(pinia)
app.use(ElementPlus)

// 初始化用户状态
const userStore = useUserStore()
userStore.initializeFromStorage()
console.log('应用启动时的用户状态:', {
  isLoggedIn: userStore.isLoggedIn,
  hasToken: !!userStore.token
})


// 使用正确的类型断言
app.use((router as unknown) as (app: App) => void)
app.mount('#app')
